package com.battle.service.repository.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.battle.pojo.entity.WarCaseStudyDetails;
import com.battle.pojo.vo.warCaseStudyDetails.GetWarCaseStudyDetailsListVo;
import com.battle.service.mapper.WarCaseStudyDetailsMapper;
import com.battle.service.repository.in.WarCaseStudyDetailsRepository;
import nirvana.core.repository.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
    import com.battle.pojo.dto.warCaseStudyDetails.*;
    import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
* 【描 述】：
* 【环 境】：J2SE
* 【详 细】：
*
*/
@Service
public class WarCaseStudyDetailsRepositoryImpl extends Repository< WarCaseStudyDetailsMapper , WarCaseStudyDetails> implements WarCaseStudyDetailsRepository {

private final WarCaseStudyDetailsMapper mapper;

public WarCaseStudyDetailsRepositoryImpl(WarCaseStudyDetailsMapper mapper) {
this.mapper = mapper;
}

    /**
    * 搜索战例研讨记录
    * @param dto
    * @return
    */
    @Override
    public Page<GetWarCaseStudyDetailsListVo> selectWarCaseStudyDetails(SelectWarCaseStudyDetailsDto dto){

    return mapper.selectWarCaseStudyDetails(dto);
    }

@Override
public  Map<Long, WarCaseStudyDetails> getMap(List<Long> ids){
    Map<Long, WarCaseStudyDetails> map = new HashMap<>();

    if (CollectionUtil.isNotEmpty(ids)) {
        List<WarCaseStudyDetails> list =listByIds(ids);
        if (CollectionUtil.isNotEmpty(list)) {
        map = list.stream().collect(Collectors.toMap(WarCaseStudyDetails::getId, pojo -> pojo));
         }
        }
        return map;
    }
}